<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>双重for循环</title>
    <script>
        // 1.打印n行n列的⭐
        /* var str = '';
        for (var i = 1; i <= 5; i++) {
            for (var j = 1; j <= 5; j++) {
                str = str + '⭐';
            }
            str = str + '\n'
        }
        console.log(str); */

        // 2.打印n行n列的⭐
        /*  var rows = prompt('请输入行数');
         var cols = prompt('请输入列数');
         var str = '';
         for (var i = 1; i <= rows; i++) {
             for (var j = 1; j <= cols; j++) {
                 str = str + "⭐";
             }
             str = str + '\n';
         }
         console.log(str); */

        // 3.打印倒三角
        /* var str = '';
        for (var i = 1; i <= 10; i++) {
            for (var j = 10 - i; j >= 1; j--) {
                str = str + '⭐';
            }
            str = str + '\n';
        }
        console.log(str); */

        // 4.九九乘法表
        var num = 0;
        var str = '';
        for (var i = 1; i <= 9; i++) {
            for (var j = 1; j <= i; j++) {
                num = i * j;
                str = str + j + 'x' + i + '=' + num + ' ';
            }
            str = str + '\n';
        }
        console.log(str);
    </script>
</head>

<body>

</body>

</html>